﻿/// <reference path="../scripts/typings/winjs/winjs.d.ts" />

declare module EditoneLibRT {
    class Track {
        guid: string;
        isAudioTrack: boolean;
        numChannels: number;
        type: string;
        name: string;
        color: string;
        volume: number;
        balance: number;
        height: number;

        addEventListener(event: string, callback: (args: any) => void): void;
        importTracks(offset: number): any; 
        hasClip(clip): boolean;
        delete(): void;

        clips: any;

    }

    class Clip {
        isAudioClip:boolean;
        type:string;
        duration: number;
        stream: Windows.Storage.Streams.IInputStream;
        addEventListener(event: string, callback: (args: any) => void): void;
        split(at: number): Clip[];

        fadeIn(): void;
        fadeOut(): void;
        normalize(): void;

        delete(): void;

        move(newtrack: Track, offset: number);
        canMoveTo(newtrack: Track, offset: number): { canMove: boolean, suggestedOffset: number };

        isLoading: boolean;
    }

    class Project {
        static create(): Project;

        createTrack(type: string, index: number);

        removeTrack(track: Track);

        tracks: Track[];

        settings: any;

        sampleRate: number;

        sampleSize: number;

        addEventListener(event: string, callback: (args: Object) => void): void;

        onPropertyChanged: (prop: string) => void;
        onSettingsChanged: (setting: string) => void;

        importTracksAsync(tickOffset: number);
        exportAsync();

        play(offset: number);
        stop();

        save(folder: Windows.Storage.StorageFolder, filename: string): WinJS.Promise<void>;
        load(folder: Windows.Storage.StorageFolder, filename: string): WinJS.Promise<Project>;

        playbackState: string;
        playbackMsec: number;
    }

    class ClipVisualizer {
        static getBase64PngArrayAsync(
            clip: Clip,
            startOffsetTicks: number,
            lengthTicks: number,
            stepTicks: number,
            height: number
            ): any;
    }
 }